package ai.zixing;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 发布事件【事件源 + 事件的发布】
 */
@Component
public class Request {

    // ApplicationContext 继承了 ApplicationEventPublisher
    @Resource
    private ApplicationContext applicationContext;

    public void doRequest() {
        System.out.println("调用Request类的doRequest方法发送一个请求......");
        applicationContext.publishEvent(new RequestEvent(this));

    }
}
